import QtQuick 2.9
import ChoiceModel 1.0
import PluginHandler 1.0

Component {
    Rectangle {
        readonly property int btnHeight: 200
        readonly property int btnWidth: 150

//        color: "yellow"
        GridView {
            id: view
            anchors.fill: parent
            anchors.left: parent.left
            anchors.leftMargin: 20
            anchors.right: parent.right
            anchors.rightMargin: 20

            boundsBehavior: Flickable.StopAtBounds

            cellWidth: 200
            cellHeight: 250

            focus: true

            model: ChoiceModel
            delegate: Component {
                Rectangle {
                    width: view.cellWidth
                    height: view.cellHeight
                    Column {
                        anchors.top: parent.top
                        anchors.topMargin: 10
                        spacing: 10
                        Loader {
                            id: loader
                            width: btnWidth
                            height: btnHeight
                            sourceComponent: cBtn

                            MouseArea {
                                anchors.fill: parent
                                enabled: true
                                hoverEnabled: true

                                onEntered: {
                                    parent.opacity = 0.7
                                }
                                onExited: {
                                    parent.opacity = 1
                                }

                                onClicked: {
                                    PluginHandler.loadPage(index)
                                }
                            }
                        }
                        Text {
                            id: txt
                            font.family: "Microsoft Yahei"
                            font.pixelSize: 16
                            anchors.horizontalCenter: parent.horizontalCenter
                            text: cName
                        }
                    }
                }
            }
        }
    }
}

